package snsdbook.engine.message;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import snsdbook.engine.FileManager;
import util.Util;

public class SynchronizeReplyMessage implements MessageInterface {

  private static final long serialVersionUID = 1485985552415541046L;
  private int message_count_;
  
  public SynchronizeReplyMessage(int message_count) {
    message_count_ = message_count;
  }
  
  @Override
  public String ProcessAsServer(ObjectInputStream is, ObjectOutputStream os) {
    Util.Send(os, this);
    return "";
  }

  @Override
  public String ProcessAsClient(ObjectInputStream is, ObjectOutputStream os,
      FileManager manager) {
    for (int i = 0; i < message_count_; ++i) {
      Util.Receive(is).ProcessAsClient(is, os, manager);
    }
    return "";
  }
  
  @Override
  public String toString() {
    return "SYNCHRONIZE REPLY, MESSAGE_CNT=" + message_count_;
  }

}
